package com.nandi.emergencyinspection.mvp.macro

import com.nandi.emergencyinspection.api.ApiServices
import com.nandi.emergencyinspection.bean.MacroPostBean
import com.tbright.ktbaselibrary.extension.response
import kotlinx.coroutines.launch

/**
 * @创建者: qingsong
 * @创建时间: 2021/3/25 13:28
 * @描述:
 */
class MacroSavePresenter : MacroSaveContract.MacroSavePresenter() {


    override fun getMacro() {
        mainScope.launch {
            mView?.showLoading()
            val singlePoetry = ApiServices.instance.getMacroAsync().response()
            mView?.showMacroResult(singlePoetry)
            mView?.hideLoading()
        }
    }

    override fun getMacroDict() {
        mainScope.launch {
            mView?.showLoading()
            val singlePoetry = ApiServices.instance.getMacroDictAsync().response()
            mView?.showMacroDictResult(singlePoetry)
            mView?.hideLoading()
        }
    }

    override fun postMacroDict(map: MacroPostBean) {
        mainScope.launch {
            mView?.showLoading()
            val singlePoetry = ApiServices.instance.postMacroAsync(macroPostBean = map).response()
            mView?.showPostMacroResult(singlePoetry)
            mView?.hideLoading()
        }
    }

}